// 封装axios函数
import request from '@/tools/request.js'
// import store from '@/store'
export const loginApi = (ruleForm) => { // 抽离登录axios请求
  return request({
    method: 'post',
    url: '/api/login',
    data: ruleForm
  })
}
export const regApi = (ruleForm) => { // 抽离注册axios请求
  return request({
    method: 'post',
    url: '/api/reg',
    data: ruleForm
  })
}
export const getUserInfo = () => { // 进入首页时获取用户信息
  return request({
    method: 'get',
    url: '/my/userinfo'
    // headers: { Authorization: store.state.token }
  })
}
export const getMenu = () => { // 进入home时获取左侧菜单列表
  return request({
    method: 'get',
    url: '/my/menus'
    // headers: { Authorization: store.state.token }
  })
}
export const changeUserinfo = (data) => { // 更新用户信息
  return request({
    method: 'PUT',
    url: '/my/userinfo',
    data
  })
}
export const changePwd = (data) => { // 更新密码
  return request({
    method: 'PATCH',
    url: '/my/updatepwd',
    data
  })
}
export const changeAvatar = (data) => { // 更新密码
  return request({
    method: 'PATCH',
    url: '/my/update/avatar',
    data: {
      avatar: data
    }
  })
}
